﻿using AnesSystem.Models;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AnesSystem.ViewModels
{
    public class UnitsComboboxCtrlViewModel : BaseViewModel<UnitsComboboxCtrlViewModel>
    {
        #region Variables

        private ObservableCollection<ConfigUnitsModel> _units;
        private ConfigUnitsModel _curUnit;

        #endregion

        #region Constructor

        public UnitsComboboxCtrlViewModel()
        {
            _units = new ObservableCollection<ConfigUnitsModel>();
            IEnumerable<ConfigUnitsModel> list = Services.ConfigUnitsModelService.Instance.FindAll();
            foreach (var item in list)
            {
                _units.Add(item);
            }
            _units.Insert(0, new ConfigUnitsModel());
        }

        #endregion

        #region Properties

        public ObservableCollection<ConfigUnitsModel> Units
        {
            get
            {
                return _units;
            }

            set
            {
                _units = value;
                RaisePropertyChanged("Units");
            }
        }

        public ConfigUnitsModel SelectedUnit
        {
            get
            {
                return _curUnit;
            }

            set
            {
                _curUnit = value;
                RaisePropertyChanged("SelectedUnit");
            }
        }

        #endregion

        #region 依赖属性

        #endregion

        #region Event

        #endregion

        #region Private Methods

        #endregion

        #region Public/Protected Methods

        #endregion

        #region EventHandlers

        #endregion
    }
}
